home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0022_Trap PAUSE Key #2.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  3KB  |  68 lines

  1. {GE> Does anyone know how to disable the pause key?
  2.  
  3.  Here's one way, done in Assembly, With example Turbo Pascal code ...
  4. }
  5. (*******************************************************************)
  6.  Program TestTrapPause;             { demo disabling the Pause key  }
  7.  Uses   Crt,                        { import CheakBreak, KeyPressed }
  8.         Dos;                        { import GetIntVec, SetIntVec   }
  9.  Var    old09Vector : Pointer;      { to hold original ISR          }
  10.         loopc,                      { a loop count                  }
  11.         ppress      : Word;         { counts Pause key presses      }
  12. {-------------------------------------------------------------------}
  13. { the following Procedures|Functions mask & count Pause keystrokes  }
  14.  Procedure InitTrapPause( oldVector : Pointer );    EXTERNAL;
  15.  Procedure TrapPause; Interrupt;                    EXTERNAL;
  16.  Function  PausePresses : Word;                     EXTERNAL;
  17.  Procedure ForgetPaUses;                            EXTERNAL;
  18.  {$L NOPAUSE.OBJ}                   { Assembly, Near calls          }
  19. {-------------------------------------------------------------------}
  20.  begin
  21.     ClrScr;
  22.     CheckBreak := False;            { don't allow Ctrl-Break        }
  23.  
  24.     GetIntVec( 9, old09Vector );    { get current keyboard ISR      }
  25.     InitTrapPause( old09Vector );   { pass vector to TrapPause      }
  26.     SetIntVec( 9, @TrapPause );     { enable TrapPause ISR          }
  27.     ForgetPaUses;                   { zero the PausePresses counter }
  28.  
  29.     loopc := 0;                     { initialize                    }
  30.     WriteLn; WriteLn( 'Press the PAUSE key... ');
  31.  
  32.     Repeat
  33.         WriteLn;
  34.         ppress := PausePresses;     { initial Pause press count     }
  35.         While (ppress = PausePresses) and (not KeyPressed)
  36.         do begin
  37.             inC( loopc ); if (loopc = 65535) then loopc := 0;
  38.             Write( loopc:5, ' you''ve pressed the Pause key ' );
  39.             Write( ppress, ' times',#13 );
  40.         end; {While}
  41.     Until KeyPressed;
  42.  
  43.     SetIntVec( 9, old09Vector );    { restore Pause & release ISR   }
  44.  
  45.  end {TestTrapPause}.
  46. (*******************************************************************)
  47.  
  48. { The following TP Program will create NOPAUSE.ARC, which contains
  49.  NOPAUSE.OBJ ...
  50.  
  51.  Program A; Var G:File; Const V:Array [ 1..279 ] of Byte =(
  52. 26,8,78,79,80,65,85,83,69,46,79,66,74,0,94,248,0,0,0,43,26,67,140,78,
  53. 194,29,1,0,0,12,128,26,0,88,224,230,13,156,48,117,230,148,113,17,100,
  54. 74,19,47,150,14,0,0,64,96,200,19,34,69,136,96,146,136,162,13,0,1,2,2,
  55. 28,131,4,32,200,196,0,12,140,60,145,114,164,8,21,40,65,170,76,41,50,165,
  56. 204,68,6,48,101,22,129,34,133,230,204,41,96,38,54,72,226,36,9,21,42,82,
  57. 130,64,201,57,115,34,128,4,72,149,50,45,226,99,34,9,68,4,38,138,10,16,
  58. 13,84,28,0,1,38,46,226,102,99,209,17,1,46,70,77,44,123,132,64,218,137,
  59. 46,142,25,112,10,64,88,214,33,6,243,200,73,115,6,13,29,16,49,114,228,
  60. 144,1,226,136,156,50,103,222,200,201,3,98,138,11,43,124,221,148,65,200,
  61. 134,14,167,125,80,200,129,225,81,132,206,1,44,157,92,252,115,1,247,223,
  62. 92,0,176,64,152,3,1,250,25,0,72,6,92,132,154,56,44,238,105,218,125,56,
  63. 201,0,64,12,1,216,0,90,120,67,248,205,133,119,133,223,94,120,51,249,29,
  64. (96 min left), (H)elp, More? 156,88,20,228,188,197,64,39,134,6,58,43,69,2,38,210,1,26,0);
  65.  begin Assign(G,'NOPAUSE.ARC'); ReWrite(G,Sizeof(V));
  66.  BlockWrite(G,V,1); Close(G); end (*Gbug1.5*).
  67. }
  68.